Expand description

A simple 2D graphics library for turning simple 2D shapes and text into textured triangles.

Made for egui.

Create some Shape:s and pass them to tessellate_shapes to generate Mesh:es that you can then paint using some graphics API of your choice (e.g. OpenGL).

Feature flags

  • bytemuckbytemuck enables you to cast Vertex to &[u8].

  • deadlock_detection — This will automatically detect deadlocks due to double-locking on the same thread. If your app freezes, you may want to enable this! Only affects mutex::RwLock (which epaint and egui uses a lot).

  • default_fonts (enabled by default) — If set, epaint will use include_bytes! to bundle some fonts. If you plan on specifying your own fonts you may disable this feature.

  • extra_debug_asserts — Enable additional checks if debug assertions are enabled (debug builds).

  • extra_asserts — Always enable additional checks.

  • mintmint enables interopability with other math libraries such as glam and nalgebra.

  • serde — Allow serialization using serde.

Optional dependencies

  • cintcint enables interopability with other color libraries.

  • color-hex — Enable the hex_color macro.

  • document-features — Enable this when generating docs.

  • serde — Allow serialization using serde .

Re-exports

pub use color::Color32;
pub use color::Rgba;
pub use image::ColorImage;
pub use image::FontImage;
pub use image::ImageData;
pub use image::ImageDelta;
pub use stats::PaintStats;
pub use tessellator::tessellate_shapes;
pub use tessellator::TessellationOptions;
pub use tessellator::Tessellator;
pub use textures::TextureManager;
pub use ahash;
pub use emath;
pub use color_hex;

Modules

Color conversions and types.

Helper module that wraps some Mutex types with different implementations.

Collect statistics about what is being painted.

Converts graphics primitives into textured triangles.

Everything related to text, fonts, text layout, cursors etc.

Macros

An assert that is only active when epaint is compiled with the extra_asserts feature or with the extra_debug_asserts feature in debug builds.

Construct a Color32 from a hex RGB or RGBA string.

Structs

How to paint a circle.

A Mesh or PaintCallback within a clip rectangle.

A Shape within a clip rectangle.

How to select a sized font.

The collection of fonts used by epaint.

Text that has been layed out, ready for painting.

Textured triangles in two dimensions.

A version of Mesh that uses 16-bit indices.

If you want to paint some 3D shapes inside an egui region, you can use this.

Information passed along with PaintCallback (Shape::Callback).

A path which can be stroked and/or filled (if closed).

A position on screen.

A rectangular region of space.

How to paint a rectangle.

How rounded the corners of things should be

The color and fuzziness of a fuzzy shape. Can be used for a rectangular shadow with a soft penumbra.

Describes the width and color of a line.

How to paint some text on screen.

Contains font data in an atlas, where each character occupied a small rectangle.

Used to paint images.

A vector has a direction and length. A Vec2 is often used to represent a size.

The 2D vertex type.

Enums

Font of unknown size.

A rendering primitive - either a Mesh or a PaintCallback.

A paint primitive such as a circle or a piece of text. Coordinates are all screen space points (not physical pixels).

What texture to use in a Mesh mesh.

Constants

The UV coordinate of a white region of the texture mesh. The default egui texture has the top-left corner pixel fully white. You need need use a clamping texture sampler for this to work (so it doesn’t do bilinear blending with bottom right corner).

Functions

pos2(x, y) == Pos2::new(x, y)

vec2(x, y) == Vec2::new(x, y)